import Vue from 'vue'
import Router from 'vue-router'

// Pages
import Index from '@/view/index/Index'
import Details from '@/view/details/Details'
import Archives from '@/view/archives/Archives'
import Tag from '@/view/Tag/Tag'

// components
import NotFound from '@/components/notFound'
import Home from '@/components/Home'

Vue.use(Router);

// 解决ElementUI导航栏中的vue-router在3.0版本以上重复点菜单报错问题
const originalPush = Router.prototype.push
Router.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}
export default new Router({
  routes: [
    {
      path: '/',
      redirect: '/webBlog'
    },
    {
      path: '/webBlog',
      name: 'Index',
      component: Index,
    },
    {
      path: '/details',
      name: 'Details',
      component: Details,
    },
    {
      path: '/home',
      name: 'Home',
      component: Home,
    },
    {
      path: '/archives',
      name: 'archives',
      component: Archives,
    },
    {
      path: '/tag',
      name: 'tag',
      component: Tag,
    },
    {
      name: '404',
      path: '/404',
      component: NotFound
    },
    {
      path: '*',
      redirect: '/404'
    }
  ],
  // mode: 'history'
})
